import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

/// 加载本地资源图片
Widget loadAssetImage(String name,
    {double? width,
    double? height,
    BoxFit? fit,
    Color? color,
    String format: 'png'}) {
  return Image.asset(
    getImgPath(name, format: format),
    height: height,
    width: width,
    fit: fit,
    color: color,
  );
}

/// 加载网络图片
Widget loadNetworkImage(String imageUrl,
    {double? width,
    double? height,
    BoxFit fit = BoxFit.cover,
    String placeHolder = ""}) {
  return CachedNetworkImage(
    imageUrl: imageUrl,
    width: width,
    height: height,
    fit: fit,
  );
}

String getImgPath(String name, {String format = 'png'}) {
  return 'assets/images/$name.$format';
}
